<!DOCTYPE html>
<html>

<head>
	<meta charset="utf-8">
	<title>账单信息</title>
	<meta name="renderer" content="webkit">
	<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
	<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
	<meta name="apple-mobile-web-app-status-bar-style" content="black">
	<meta name="apple-mobile-web-app-capable" content="yes">
	<meta name="format-detection" content="telephone=no">
	<link rel="stylesheet" href="../plugins/layui/css/layui.css" media="all" />
	<link rel="stylesheet" href="../plugins/font-awesome/css/font-awesome.min.css">
</head>

<body>
	<div style="margin: 15px;">
		<blockquote class="layui-elem-quote">
			<a href="javascript:history.go(-1);;" class="layui-btn layui-btn-small" id="add">
					<i class="layui-icon">&#xe608;</i> 返回
				</a>
		</blockquote>

		<fieldset class="layui-elem-field layui-field-title" style="margin-top: 20px;">
			<legend>账单详细信息</legend>
		</fieldset>

		<form class="layui-form" action="">
			<div id="content">

			</div>
		</form>
	</div>

	<!--模板-->
	<script type="text/html" id="tpl">

		<div class="layui-form-item">
			<label class="layui-form-label">id</label>
			<div class="layui-input-block">
				<input type="text" value="<%==result.caid %>" disabled="true" name="title" lay-verify="title" autocomplete="off" class="layui-input">
			</div>
		</div>
		<div class="layui-form-item">
			<label class="layui-form-label">订单号</label>
			<div class="layui-input-block">
				<input type="text" value="<%==result.allOrderNum %>" disabled="true" name="username" lay-verify="required" placeholder="请输入" autocomplete="off" class="layui-input">
			</div>
		</div>
		<div class="layui-form-item">
			<label class="layui-form-label">支付单号</label>
			<div class="layui-input-block">
				<input type="text" value="<%==result.tradeNo %>" disabled="true" name="phone" lay-verify="phone" autocomplete="off" class="layui-input">
			</div>
		</div>
		<div class="layui-form-item">
			<label class="layui-form-label">支付方式</label>
			<div class="layui-input-inline">
				<% var payWay=["支付宝","微信"]; %>
				<input type="text" value="<%==payWay[result.payWay] %>" disabled="true" name="email" lay-verify="email" autocomplete="off" class="layui-input">
			</div>
		</div>
		<div class="layui-form-item">
			<label class="layui-form-label">付款金额</label>
			<div class="layui-input-inline">
				<input type="text" value="<%==result.totalAmount %>" disabled="true" name="email" lay-verify="email" autocomplete="off" class="layui-input">
			</div>
		</div>
		<div class="layui-form-item">
			<label class="layui-form-label">状态</label>
			<div class="layui-input-inline">
				<% var status=["未支付","支付未消费","支付已消费"]; %>
				<input type="text" value="<%==status[result.status] %>" disabled="true" name="email" lay-verify="email" autocomplete="off" class="layui-input">
			</div>
		</div>
		<div class="layui-form-item">
			<label class="layui-form-label">支付账号</label>
			<div class="layui-input-inline">
				<input type="text" value="<%==result.buyerLogonId %>" disabled="true" name="email" lay-verify="email" autocomplete="off" class="layui-input">
			</div>
		</div>
		<div class="layui-form-item">
			<label class="layui-form-label">退款金额</label>
			<div class="layui-input-inline">
				<input type="text" value="<%==result.refundFee %>" disabled="true" name="email" lay-verify="email" autocomplete="off" class="layui-input">
			</div>
		</div>
		<div class="layui-form-item">
			<label class="layui-form-label">付款时间</label>
			<div class="layui-input-inline">
				<input type="text" value="<%==result.gmtPayment %>" disabled="true" name="email" lay-verify="email" autocomplete="off" class="layui-input">
			</div>
		</div>
		<div class="layui-form-item">
			<label class="layui-form-label">退款时间</label>
			<div class="layui-input-inline">
				<input type="text" value="<%==result.gmtRefund %>" disabled="true" name="email" lay-verify="email" autocomplete="off" class="layui-input">
			</div>
		</div>
		<div class="layui-form-item layui-form-text">
			<label class="layui-form-label">关联订单</label>
			<div class="layui-input-block">
				<table class="layui-table">
					<colgroup>
						<col width="150">
						<col width="200">
						<col>
					</colgroup>
					<thead>
						<tr>
							<th>类型</th>
							<th>数量</th>
							<th>商品</th>
							<th>订单详细</th>
						</tr>
					</thead>
					<tbody>
						<%for(var i=0;i<result.orders.length;i++){%>
						<tr>
							<td><%==result.orders[i].productType%></td>
							<td><%==result.orders[i].number%></td>
							<td><a  onclick="check(<%==result.orders[i].productId %>,'<%==result.orders[i].productType %>')" >查看商品</a></td>
							<td><a href="/admin/order/info?id=<%==result.orders[i].spid%>">查看订单详细</a></td>
						</tr>
						<%}%>
					</tbody>
				</table>
			</div>
		</div>

		<br/><br/><br/><br/><br/>
	</script>

	<script type="text/javascript" src="../plugins/layui/layui.js"></script>
	<script type="text/javascript" src="../js/jquery.min.js"></script>
	<script type="text/javascript" src="../js/template.js"></script>
	<script type="text/javascript" src="../js/public.js"></script>
	<script type="text/javascript" src="../js/jquery.min.js"></script>
	<script>
		var data;
		var id = getUrlParam("id");
		$.ajax({
			url: '/admin/bill/get?allOrderNum=' + id,
			dataType: 'json',
			async: false,
			success: function(response) {
				if (response.code == 200) {
					data = response;
					data.result.gmtPayment = data.result.gmtPayment==null ? '':new Date(data.result.gmtPayment).format("YYYY-MM-dd h:m:s");
					data.result.gmtRefund = data.result.gmtRefund==null ? '':new Date(data.result.gmtRefund).format("YYYY-MM-dd h:m:s");
				}
			}
		});
		var html = template('tpl', data);
		document.getElementById('content').innerHTML = html;
		layui.use(['layer'], function() {

		 layer = layui.layer;

		});
		function check(id, type) {
			var base = "http://" + document.domain + ":8080/";
			if (type == "场地") {
				var url = base + "site/detail?id=" + id;
			}
			if (type == "聚会套餐") {
				var url = base + "meal/detail?id=" + id;
			}
			if (type == "二级服务") {
				var url = base + "service/detail?sid=" + id;
			}
			layer.open({
				title: "查看商品",
				type: 2,
				content: url,
				area: ["350px", "600px"],
			});
		}
	</script>
</body>

</html>
